<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>30-过滤器基本用法</title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
    <style></style>
  </head>
  <body>
    <div id="app">
      <h3>{{msg | ToUpper}}</h3>
      <h3>{{info | lower}}</h3>
    </div>
    <script>
      Vue.filter('ToUpper', function (val) {
        return val.charAt(0).toUpperCase(0) + val.slice(1);
      });
      var vm = new Vue({
        el: '#app',
        data: {
          msg: 'hello',
          info: 'Sayhi',
        },
        methods: {},
        filters: {
          lower: function (val) {
            return val.charAt(0).toLowerCase(0) + val.slice(1);
          },
        },
      });
    </script>
  </body>
</html>
